-- card: 5118 from stack: in -- bmap block id: 0 -- flags: 0000 -- background id: 4755 -- name: -- part 6 (field) -- low flags: 00 -- high flags: 0007 -- rect: left=30 top=78 right=296 bottom=478 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 4 -- text size: 9 -- style flags: 0 -- line height: 12 -- part name: -- part 7 (button) -- low flags: 00 -- high flags: 0001 -- rect: left=13 top=29 right=57 bottom=351 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: New Button -- part contents for background part 7 ----- text ----- 40 -- part contents for background part 29 ----- text ----- -- part contents for card part 6 ----- text ----- /* * FILE: student.person.c * AUTHOR: R.G. * CREATED: June 7, 1990 * * Think C program illustrating derivation of the Student class * from the Person class. * * PROJECT CONTENTS: * student.person.c, ANSI, oops libraries */ # include # include /****************************************************************** * Definition of Person class and its methods (no changes here!) ******************************************************************/ struct Person:indirect { int age; int weight; void set(void); void print(void); }; void Person::set(void) { int new_age, new_weight; printf("Enter age and weight separated by spaces:\n"); scanf("%d %d",&new_age,&new_weight); age = new_age; weight = new_weight; } void Person::print(void) { printf("My age is %d\n",age); printf("My weight is %d\n",weight); } /****************************************************************** * Definition of new Student class and its methods ******************************************************************/ struct Student:Person { int id_number; void set(void); void print(void); }; void Student::set(void) { int new_id; printf("Enter student id number:\n"); scanf("%d",&new_id); id_number = new_id; inherited::set(); } void Student::print(void) { printf("My id number is %d\n",id_number); inherited::print(); } /****************************************************************** * main() function (only one change) ******************************************************************/ main() { Person *person; person = new(Student); person->set(); person->print(); delete(person); } -- part contents for background part 4 ----- text ----- A TC program using the Person and Student classes: -- part contents for background part 6 ----- text ----- Derivation of Student class from Person class